package org.framework.define.bean.entity.converter;

import java.sql.Timestamp;
import java.util.Date;

import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.mapper.Mapper;

public class NullConverter implements Converter {

	@SuppressWarnings("rawtypes")
	@Override
	public boolean canConvert(Class paramClass) {
		return paramClass.equals(Date.class) || paramClass.equals(Timestamp.class) || paramClass.equals(String.class);
		//return ((paramClass == null) || (Mapper.Null.class.isAssignableFrom(paramClass)));
	}

	@Override
	public void marshal(Object paramObject, HierarchicalStreamWriter paramHierarchicalStreamWriter, MarshallingContext paramMarshallingContext) {
		ExtendedHierarchicalStreamWriterHelper.startNode(paramHierarchicalStreamWriter, "null", Mapper.Null.class);
		paramHierarchicalStreamWriter.endNode();
	}

	@Override
	public Object unmarshal(HierarchicalStreamReader paramHierarchicalStreamReader, UnmarshallingContext paramUnmarshallingContext) {
		// TODO Auto-generated method stub
		return null;
	}
} 